package user;

import book.BookList;
import operation.IOperation;

public abstract class User {
    protected String name;
    protected IOperation[] iOperations;//暂时不进行初始化,根据子类不同需求进行二次初始化
    public User(String name) {
        this.name = name;
    }
    public abstract int menu();//菜单
    /**
     * 根据下标调用方法的work()方法
     */
    public void doOperation(int choice, BookList bookList) {
        //简单写法
        IOperation iOperation = this.iOperations[choice];//通过下标找到对应类
        iOperation.work(bookList);//调用类work方法
        //精简写法
       //this.iOperations[choice].work(bookList);
    }
}
